//
//  SYRequestAPI+HomePage.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/5/7.
//  Copyright © 2019 SanYi. All rights reserved.
//

NSString *const HOME_Notice_url = @"notice/NoticeReceiveService.svc/GetNoticeInfo";

NSString *const HOME_Notice_Unread_url = @"notice/NoticeReceiveService.svc/GetNoHandleNoticeInfo";


#import "SYRequestAPI+HomePage.h"

@implementation SYRequestAPI (HomePage)
+ (void)sy_getAdvertService:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOMEOAGE_ADSERVICEURL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"重置密码失败%@",error);
        if (fail) {
            fail(error);
        }
    }];
}
/**
 角色菜单
 
 @param parama 参数
 @param success 成功
 @param fail 失败
 */
+ (void)sy_getRoleMenu:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:JIAOSECAIDANURL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"角色菜单失败%@",error);
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)sy_getHomeWork:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_ZUOYE_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"最新作业失败%@",error);
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)sy_getClassList:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_TEACHERCLASSLIST_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"老师班级%@",error);
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)sy_getTheForthcomingCourse:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_THEFORTHCOMINGCOURSE_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"即将上线的课程%@",error);
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)sy_getQuestionTutor:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_QuestionTutor_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"e问题信息辅导 %@",error);
        if (fail) {
            fail(error);
        }
    }];
}
+ (void)sy_getTrain:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_Train_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"师训信息 %@",error);
        if (fail) {
            fail(error);
        }
    }];
}


+ (void)sy_getOnLineTutor:(NSDictionary *)parama success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    [SYRequestAPI postDataFromURLScheme:HOME_OnLineTutor_URL parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
        NSLog(@"在线辅导信息 %@",error);
        if (fail) {
            fail(error);
        }
    }];
}
//消息列表
+ (void)sy_getNoticeNoticeReceiveServiceGetNoticeInfo:(NSDictionary *)parama isUnread:(BOOL)isunread success:(void(^)(id responseObject))success fail:(FailBlock)fail{
    NSString *url = nil;
    if (isunread == YES) {
        url = HOME_Notice_url;
    } else {
        url = HOME_Notice_Unread_url;
    }
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:parama success:^(id responseObject) {
        success(responseObject);
    } fail:^(NSError *error) {
//        NSLog(@"得到消息列表失败 %@",error);
        if (fail) {
            fail(error);
        }
    }];
}
//首页班级消息列表
+ (void)sy_postNoticeReceiveServiceMsgClassInfoSuccess:(void(^)(NSArray *dataListArr))success
                                                  fail:(FailBlock)fail
{
    NSString *url = @"notice/NoticeReceiveService.svc/GetMsgClassInfo";
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:nil success:^(id responseObject) {
        NSArray *data = responseObject[@"data"];
        if (success) {
            success(data);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
/// 消息列表 新
/// @param classId 班级id
/// @param success 1
/// @param fail 0
+ (void)sy_postNoticeReceiveServiceGetNoticeInfoNewClassId:(NSString *)classId
                                                   success:(void(^)(NSArray *dataListArr))success
                                                      fail:(FailBlock)fail
{
    
    NSString *url = @"notice/NoticeReceiveService.svc/GetNoticeInfoNew";
    NSDictionary *dict = @{@"classId":classId};
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *data = responseObject[@"data"];
        if (success) {
            success(data);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
    
}
@end
